<?php

declare(strict_types=1);

use Phinx\Seed\AbstractSeed;

class MenuSeeder extends AbstractSeed
{
    /**
     * Run Method.
     */
    public function run(): void
    {
        // 创建默认菜单
        $menuTable = $this->table('menu');
        $menus = [
            // 一级菜单
            [
                'parent_id' => 0,
                'name' => '系统管理',
                'path' => '',
                'component' => '',
                'icon' => 'setting',
                'permission' => null,
                'type' => 'menu',
                'method' => null,
                'status' => 1,
                'sort' => 0,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 0,
                'name' => '系统监控',
                'path' => '',
                'component' => '',
                'icon' => 'monitor',
                'permission' => null,
                'type' => 'menu',
                'method' => null,
                'status' => 1,
                'sort' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            // 管理员管理及相关按钮权限
            [
                'parent_id' => 1,
                'name' => '管理员管理',
                'path' => 'admin/admin/index',
                'component' => 'admin/admin/index',
                'icon' => 'user',
                'permission' => 'admin:admin:index',
                'type' => 'menu',
                'method' => 'GET',
                'status' => 1,
                'sort' => 0,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 3,
                'name' => '查看',
                'path' => 'admin/admin/info',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:admin:info',
                'type' => 'button',
                'method' => 'GET',
                'status' => 1,
                'sort' => 0,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 3,
                'name' => '添加',
                'path' => 'admin/admin/create',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:admin:create',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 3,
                'name' => '编辑',
                'path' => 'admin/admin/update',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:admin:update',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 2,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 3,
                'name' => '删除',
                'path' => 'admin/admin/delete',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:admin:delete',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 3,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 3,
                'name' => '授权角色',
                'path' => 'admin/admin/grantRoles',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:admin:grantRoles',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 4,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            // 角色管理及相关按钮权限
            [
                'parent_id' => 1,
                'name' => '角色管理',
                'path' => 'admin/role/index',
                'component' => 'admin/role/index',
                'icon' => 'team',
                'permission' => 'admin:role:index',
                'type' => 'menu',
                'method' => 'GET',
                'status' => 1,
                'sort' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 9,
                'name' => '查看',
                'path' => 'admin/role/info',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:role:info',
                'type' => 'button',
                'method' => 'GET',
                'status' => 1,
                'sort' => 0,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 9,
                'name' => '添加',
                'path' => 'admin/role/create',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:role:create',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 9,
                'name' => '编辑',
                'path' => 'admin/role/update',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:role:update',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 2,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 9,
                'name' => '删除',
                'path' => 'admin/role/delete',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:role:delete',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 3,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 9,
                'name' => '授权菜单',
                'path' => 'admin/role/grantMenus',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:role:grantMenus',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 4,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            // 菜单管理及相关按钮权限
            [
                'parent_id' => 1,
                'name' => '菜单管理',
                'path' => 'admin/menu/index',
                'component' => 'admin/menu/index',
                'icon' => 'menu',
                'permission' => 'admin:menu:index',
                'type' => 'menu',
                'method' => 'GET',
                'status' => 1,
                'sort' => 2,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 15,
                'name' => '查看',
                'path' => 'admin/menu/info',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:menu:info',
                'type' => 'button',
                'method' => 'GET',
                'status' => 1,
                'sort' => 0,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 15,
                'name' => '添加',
                'path' => 'admin/menu/create',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:menu:create',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 15,
                'name' => '编辑',
                'path' => 'admin/menu/update',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:menu:update',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 2,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 15,
                'name' => '删除',
                'path' => 'admin/menu/delete',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:menu:delete',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 3,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            // 行为日志管理及相关按钮权限
            [
                'parent_id' => 2,
                'name' => '行为日志',
                'path' => 'admin/actionlog/index',
                'component' => 'admin/actionlog/index',
                'icon' => 'file-excel',
                'permission' => 'admin:actionlog:index',
                'type' => 'menu',
                'method' => 'GET',
                'status' => 1,
                'sort' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 20,
                'name' => '查看',
                'path' => 'admin/actionlog/info',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:actionlog:info',
                'type' => 'button',
                'method' => 'GET',
                'status' => 1,
                'sort' => 0,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 20,
                'name' => '删除',
                'path' => 'admin/actionlog/delete',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:actionlog:delete',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id' => 20,
                'name' => '批量删除',
                'path' => 'admin/actionlog/batchDelete',
                'component' => '',
                'icon' => '',
                'permission' => 'admin:actionlog:batchDelete',
                'type' => 'button',
                'method' => 'POST',
                'status' => 1,
                'sort' => 2,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s'),
            ],
        ];
        $menuTable->insert($menus)->saveData();
        echo "默认菜单创建成功！\n";
    }
}
